package com.lt.test.provider.mapper;

import com.lt.test.common.model.MinShengClearingResponseDTO;
import com.lt.test.entity.DO.ClearingDO;
import com.lt.test.entity.DTO.ClearingOrderDTO;

import java.util.List;
import java.util.Map;

/**
 * Created by zhengchuan on 2017/5/11.
 * 清算操作数据库
 */
public interface ClearingMapper {
    /**
     * 获取本地订单指定时间，指定商户号的订单数量
     * @param params
     * @return
     */
    Long getQrOrderCount(Map<String, String> params) throws Exception;

    /**
     * 获取远程对账订单指定时间，指定商户号的订单数量
     * @param params
     * @return
     * @throws Exception
     */
    Long getYnionCount(Map<String, String> params) throws Exception;

    /**
     * 对账两个表的订单是否相等
     * @param params
     * @return
     */
    Long getClearOrderCount(Map<String, String> params) throws Exception;

    /**
     * 查询对账信息，时间和商户号
     * @param params
     * @return
     * @throws Exception
     */
    ClearingDO getClearingBydateAndmerId(Map<String, String> params) throws Exception;

    /**
     * 插入对账信息
     * @param clearingDO
     * @throws Exception
     */
    void insert(ClearingDO clearingDO) throws Exception;

    /**
     * 更新对账信息
     * @param clearingDO
     * @throws Exception
     */
    void update(ClearingDO clearingDO) throws Exception;

    /**
     * 查询目前为止，没有清算的订单
     * @return
     * @throws Exception
     * @param now
     */
    List<ClearingOrderDTO> selectNotClearingOrder(String now) throws Exception;

    /**
     * 查询出所有符合更新的订单
     * @param clearState
     * @return
     * @throws Exception
     */
    List<String> getOrderToUpdate(Map<String, String> clearState) throws Exception;
    /**
     * 更新本地订单的状态
     * @param clearState
     * @throws Exception
     */
    void updateQrOrder(Map<String, String> clearState) throws Exception;

    /**
     * 更新远程拉取的订单数据
     * @param clearState
     * @throws Exception
     */
    void updatePlatformClearingOrder(Map<String, String> clearState) throws Exception;

    /**
     *插入到清算记录
     * @param clearState
     * @throws Exception
     */
    void insertClearingData(Map<String, String> clearState) throws Exception;
    /**
     * 更新本地订单的状态
     * @throws Exception
     */
    void updateQrOrderByResponse(MinShengClearingResponseDTO minShengClearingResponseDTO) throws Exception;

    /**
     * 获取订单id用来更新
     * @param orderId
     * @return
     */
    List<String> getDQrOrderIdToUpdate(String orderId)  throws Exception;
    /**
     * 更新远程拉取的订单数据
     * @throws Exception
     */
    void updatePlatformClearingOrderByResponse(MinShengClearingResponseDTO minShengClearingResponseDTO) throws Exception;
    /**
     *更新清算记录
     * @throws Exception
     */
    void updateClearingDataByResponse(MinShengClearingResponseDTO minShengClearingResponseDTO) throws Exception;


    void updateClearingData(Map<String, String> clearState) throws Exception;

    Map<String,Long> getClearingParams() throws Exception;
}
